﻿using System.Collections.Generic;
using Xms.Abp.Authorization;
using Volo.Abp.Json;
using Volo.Abp.Json.Newtonsoft;
using Volo.Abp.Json.SystemTextJson;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
using Xms.Abp.Application;
using FeatureManagement.JsonConverters;

namespace FeatureManagement;

[DependsOn(
    typeof(FeatureManagementDomainSharedModule),
    typeof(XmsAbpDddApplicationContractsModule),
    typeof(XmsAbpAuthorizationAbstractionsModule),
    typeof(AbpJsonModule)
    )]
public class FeatureManagementApplicationContractsModule : XmsAbpDddApplicationContractsBaseModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        base.ConfigureServices(context);

        Configure<AbpVirtualFileSystemOptions>(options =>
        {
            options.FileSets.AddEmbedded<FeatureManagementApplicationContractsModule>();
        });

        Configure<AbpNewtonsoftJsonSerializerOptions>(options =>
        {
            options.Converters.Add<NewtonsoftStringValueTypeJsonConverter>();
        });

        Configure<AbpSystemTextJsonSerializerOptions>(options =>
        {
            options.JsonSerializerOptions.Converters.AddIfNotContains(new StringValueTypeJsonConverter());
        });
    }
}
